The implementation of Basename in release 9.3.1 was
procedure basename(name, suffix) #: base name of file
local i
name ? {
every i := upto('/\\:')
tab(integer(i) + 1) # get rid of path, if any
return tab(find(\suffix | ".") | 0) # return part before suffix, if any
}
end
In release 9.3.2 Basename has become a little "safer" ("Basename xyzzy.c .cpp" returns xyzzy.c not xyzzy)
procedure basename(name, suffix) #: base name of file
local i, base
name ? {
every i := upto('/\\:')
tab(integer(i) + 1) # get rid of path, if any
if base := 1(tab(find(\suffix)), pos(-*suffix)) then return base
else return tab(0)
}
end
I like the new version, it's the Basename that I know and love, but the behavior has actually changed and the documentation doesn't reflect that (so I don't know if the behavior is intended or not). The file documentation says that
# If no suffix is provided, the portion of the name up to the first
# "." is returned.
I think that that is no longer true and that the new Basename returns the simple filename, with suffix, if no suffix is specified.
Am I correct? (I'm an Icon newbie and I'm confused as to whether I'm confused...)
Is the behavior intended?
Should the documentation be corrected?
(* BTW
I'm using Icon 9.0 on MacOS 8 under the MPW Shell.
I'm looking forward to using Icon graphics procedures when 9.3 is done for Macintosh.
I'll implement it myself if necessary but right now I'm working on compiling release 9.0 with MrC.